package com.xyy.saas.payment.service.impl;

import com.xyy.saas.payment.dao.mapper.AutoCheckBillMapper;
import com.xyy.saas.payment.dao.model.AutoCheckBill;
import com.xyy.saas.payment.dao.model.AutoCheckBillParam;
import com.xyy.saas.payment.service.AutoCheckBillService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * (AutoCheckBill)表服务实现类
 *
 * @author makejava
 * @since 2021-01-08 15:30:57
 */
@Service("autoCheckBillService")
public class AutoCheckBillServiceImpl implements AutoCheckBillService {
    @Resource
    private AutoCheckBillMapper autoCheckBillDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public AutoCheckBill queryById(Integer id) {
        return this.autoCheckBillDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<AutoCheckBill> queryAllByLimit(int offset, int limit) {
        return this.autoCheckBillDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<AutoCheckBill> queryAll(AutoCheckBill autoCheckBill) {
        return autoCheckBillDao.queryAll(autoCheckBill);
    }

    /**
     * 新增数据
     *
     * @param autoCheckBill 实例对象
     * @return 实例对象
     */
    @Override
    public AutoCheckBill insert(AutoCheckBill autoCheckBill) {
        autoCheckBill.setCreateTime(new Date());
        autoCheckBill.setUpdateTime(new Date());
        this.autoCheckBillDao.insert(autoCheckBill);
        return autoCheckBill;
    }

    /**
     * 修改数据
     *
     * @param autoCheckBill 实例对象
     * @return 实例对象
     */
    @Override
    public AutoCheckBill update(AutoCheckBill autoCheckBill) {
        this.autoCheckBillDao.update(autoCheckBill);
        return this.queryById(autoCheckBill.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.autoCheckBillDao.deleteById(id) > 0;
    }

    @Override
    public List<AutoCheckBill> queryByNoAndType(AutoCheckBill bill) {
        return autoCheckBillDao.queryByNoAndType(bill);
    }

    @Override
    public int insertOrUpdateBatch(List<AutoCheckBill> entities) {
        return autoCheckBillDao.insertOrUpdateBatch(entities);
    }

    @Override
    public int insertBatch(List<AutoCheckBill> entities) {
        return autoCheckBillDao.insertBatch(entities);
    }

    @Override
    public List<AutoCheckBill> queryByPage(AutoCheckBillParam param) {
        return autoCheckBillDao.queryByPage(param);
    }

    @Override
    public Integer getTotal(AutoCheckBillParam param) {
        return autoCheckBillDao.getTotal(param);
    }
}